<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <p:messages />
                <h:outputText escape="false" value="#{bundleFuncionario.ListFuncionarioEmpty}" rendered="#{funcionarioController.listaFunionario eq null}"/>
                <h:panelGroup rendered="#{funcionarioController != null}">

                    <p:dataTable value="#{funcionarioController.listaFunionario}" var="item" rows="10"
                                 paginator="true"
                                 firstPageLinkLabel="#{bundlePrincipal.Primeiro}"
                                 lastPageLinkLabel="#{bundlePrincipal.Ultimo}"
                                 nextPageLinkLabel="#{bundlePrincipal.Proximo}"
                                 previousPageLinkLabel="#{bundlePrincipal.Anterior}"
                                 emptyMessage="Sem itens encontrados">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle_nome}"/>
                            </f:facet>
                            <h:outputText value="#{item.nome}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle_cpf}"/>
                            </f:facet>
                            <h:outputText value="#{item.cpf}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle_rg}"/>
                            </f:facet>
                            <h:outputText value="#{item.rg}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle_endereco}"/>
                            </f:facet>
                            <h:outputText value="#{item.endereco}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle_email}"/>
                            </f:facet>
                            <h:outputText value="#{item.email}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleFuncionario.ListFuncionarioTitle_telefone}"/>
                            </f:facet>
                            <h:outputText value="#{item.telefone}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{funcionarioController.prepareView}" value="#{bundleFuncionario.ListFuncionarioViewLink}">
                                <f:setPropertyActionListener value="#{item}" target="#{funcionarioController.selected}" />
                            </h:commandButton>

                            <h:outputText value=" "/>
                            <h:commandButton action="#{funcionarioController.prepareEdit}" value="#{bundleFuncionario.ListFuncionarioEditLink}">
                                <f:setPropertyActionListener value="#{item}" target="#{funcionarioController.selected}" />
                                <f:setPropertyActionListener target="#{funcionarioController.senha}"  value="false" />
                            </h:commandButton>
                            <h:outputText value=" "/>
                            <p:commandButton value="#{bundleFuncionario.ListFuncionarioDestroyLink}" onclick="dialogo.show();"
                                           >
                                <f:setPropertyActionListener value="#{item}" target="#{funcionarioController.selected}" />
                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                <br />
                <h:commandButton action="#{funcionarioController.prepareCreate}" value="#{bundleFuncionario.ListFuncionarioCreateLink}"/>
                <br />
                <br />
                <h:commandButton value="#{bundleFuncionario.ListFuncionarioIndexLink}" action="/restrito/index" immediate="true" />
            </h:form>
            <p:dialog widgetVar="dialogo" fixedCenter="true" height="150px"
                      width="250px" modal="true" visible="block" id="diagConfirmacao"
                      header="Deseja excluir este item?">
                <h:form>
                    <h:panelGrid columns="2">
                        <p:commandButton value="SIM" action="#{funcionarioController.destroy}" ajax="false" oncomplete="dialogo.hide();"/>
                        <h:commandButton value="NÃO" onclick="dialogo.hide(); return false;" />
                    </h:panelGrid>
                </h:form>
            </p:dialog>
        </ui:define>
    </ui:composition>

</html>
